<template>
  <div class="tableData-wrap">
    <!-- <h2>初始版</h2>
    <el-table :data="tableData">
      <el-table-column
        v-for="{prop, label} in colConfigs"
        :key="prop"
        :prop="prop"
        :label="label"
      >
      </el-table-column>
    </el-table> -->
    <h2>slot封装</h2>
    <el-table :data="data">
      <template v-for="colConfig in colConfigs">
        <slot v-if="colConfig.slot" :name="colConfig.slot"></slot>
        <!-- <component
          v-else-if="colConfig.component"
          :is="colConfig.component"
          :colConfig="colConfig"
        ></component> -->
        <component
          :is="component"
        ></component>
        <el-table-column v-bind="colConfig"></el-table-column>
      </template>
    </el-table>
  </div>
</template>

<script lang="ts">
  import { Component, Vue, Prop } from "vue-property-decorator"

  @Component({})

  export default class TableData extends Vue {
    @Prop({
      required: false,
      default: []
    }) colConfigs!: any[]
    @Prop({
      required: false,
      default: []
    }) data!: any[]
    // colConfigs:colConfigClass[] = [
    //   { prop: 'date', label: '日期' },
    //   { prop: 'name', label: '姓名' },
    //   { prop: 'address', label: '地址' },
    //   { prop: 'hover', label: '爱好'}
    // ]
    
    

    created() {
    }
  }
  export class TableDataClass{
    'date': string
    'name': string
    'address': string
    'hover': string
  }
  export class colConfigClass{
    'prop': string
    'label': string
  }
</script>

<style lang="scss" scoped>
  @import "@/assets/scss/variables";

  .tableData-wrap {
    width: 100%;
  }
</style>

